window.onload=function(){
    var url = '/shop-order/index';
    var config = {
        elem:"#userTable",
        url:url,
        cols:[[
            {type:'numbers', width:80, title: '编号'},
            {field:'order_no', width:200, title: '订单编号'},
            {field:'created_time', width:120, title: '下单时间',templet:function (item) {
                    return timestampToTime(parseInt(item.created_time));
                }},
            {field:'order_money', width:86, title: '订单金额'},
            {field:'order_status', width:86, title: '订单状态',templet:function (item) {
                    return getStatus(parseInt(item.order_status));
                }},
            {field:'addressee_name', width:88, title: '用户姓名'},
            {field:'addressee_phone', width:120, title: '手机号'},
            {field:'remark', width:86, title: '订单备注'},
            {fixed:'right', width:150, align:'center', toolbar: '#operation',title:'操作'}
        ]],
        page:true
    };
    layui.use(['table','laydate','form','layer'],function(){
        var table=layui.table,
            form = layui.form,
            $=layui.$,
            laydate=layui.laydate;
        table.render(config);
        //监听工具条
        table.on('tool(operation)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            if(layEvent === 'detail'){ //查看
                location.href = '/order/get-info?id='+data.id;
            }
        });
        laydate.render({
            elem:'#start_time'
        });
        laydate.render({
            elem: '#end_time'
        });


        //搜索
        form.on("submit(serch-form)",function(data){
            var query = $("#serch-form").serialize();
            var url = '/shop-order/index?'+ query;
            config.url = url;
            table.render(config);
            return false;

        });
    })
}